package mysql

import "gorm.io/gorm"

type ClassPlan struct {
	gorm.Model
	UserId  int     `gorm:"type:int;comment:用户id"`
	ClassId int     `gorm:"type:int;comment:课程id"`
	Name    string  `gorm:"type:varchar(20);comment:课程名称"`
	Price   float64 `gorm:"type:decimal(10,2);comment:课程价格"`
}

func (ClassPlan) TableName() string {
	return "class_plan"
}

func (p *ClassPlan) AddClassPlan() error {
	return DB.Create(&p).Error
}

func (p *ClassPlan) DelClassPlan(classPlanId int32, userId int32) error {
	return DB.Where("user_id=?", userId).Find(&p).Delete("id", classPlanId).Error
}
